nginx 默认配置时带下划线的header被过滤掉

作者 Billy 日期 2024-06-24
nginx 默认配置时带下划线的header被过滤掉

nginx 默认配置时带下划线的header被过滤掉

http请求header中带有下划线不向后端转发,必须添加underscores_in_headers on; 参数到 default server中

server {
listen 443 ssl;
server_name test.*******.com;
ssl_certificate /etc/letsencrypt/live/test.*******.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.*******.com/privkey.pem;
ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

underscores_in_headers on;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:9001/;
}

location /chat {
proxy_pass http://127.0.0.1:9001/chat;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}